<?php
session_start();
require "../util/DBUtil.php";


/**
 * 显示已付款订单
 */
function hasPaid(){
    $sql = "select book.bookName,item.* from book,item where book.bookNo=item.bookNo and item.pay=1";
    $db = new DBUtil();
    $resultSet = $db->query($sql);
    foreach ($resultSet as $bookInfo){
        echo "<tr><td>".$bookInfo['bookName']."</td><td>".$bookInfo['bookNum']."</td><td>".$bookInfo['onePrice']."</td>
<td>".$bookInfo['buyDate']."</td><td>".$bookInfo['bookNum']*$bookInfo['onePrice']."</td><td><a href='#?id=$bookInfo[id]'>确认收货</a></td></tr>";
    }
}

/**
 * 显示已收货订单
 */
function hasRecord(){
    $userId = unserialize($_SESSION['login_user'])['id'];
    $sql = "select book.bookName,record.* from book,record where book.bookNo=record.bookNo and record.userID=".$userId;
    $db = new DBUtil();
    $resultSet = $db->query($sql);
    foreach ($resultSet as $bookInfo){
        echo "<tr><td>".$bookInfo['bookName']."</td><td>".$bookInfo['bookNum']."</td><td>".$bookInfo['onePrice']."</td>
<td>".$bookInfo['buyDate']."</td><td>".$bookInfo['receiptDate']."</td><td><a href='#?id=$bookInfo[id]'>删除</a></td></tr>";
    }
}
